<template>
	<view class="mainpadding">
		<view class="flexcenter margin_top6">
			<uqrcode ref="uqrcode" canvas-id="qrcode" @click="ewmfn" v-bind:value="qrcodeurl"
				:options="{ margin: 10}" size="300">
			</uqrcode>
		</view>
		<!-- <view class="erwem">
			<image src="../static/logo.png" mode=""></image>
		</view> -->
		<view class="flexcenter margin_top">
			<view class="xihbtn margin_right4" @click="yibaoma">医保码</view>
			<view class="xihbtn">微信支付码</view>
		</view>
	</view>
</template>

<script>
	const httpRequest = require("@/common/httpRequest.js")
	export default {
		data() {
			return {
				qrcodeurl:""
			}
		},
		onLoad() {
			this.getcaigouma()
		},
		methods: {
			yibaoma(){
				uni.navigateToMiniProgram({
					// appid  写你要跳转的小程序的 appid
					appId: "wx7ec43a6a6c80544d",
					// 路径写  src下的路径,假如你跳转的是pages下的页面,就可以写pages/index
					path: "pages/new_index/index/index",
					extraData: {
						// 'type': 'out'
					},
					// 这个不写的话会显示开发环境,不能正常跳转,写上就能正常跳转了
					envVersion: 'release',
					success(res) {
						// 打开成功
						console.log("跳转成功");
						// uni.showToast({
						// 	title: '跳转成功'
						// })
					},
					fail(err) {
						// 打开失败/取消
						console.log("跳转不成功");
						// uni.showToast({
						// 	title: '跳转不成功'
						// })
					}
				})
			},
			ewmfn() {
				this.$refs.uqrcode.toTempFilePath({
					success: res => {
						console.log(res);
						var i = [res.tempFilePath]; //获取当前页面的轮播图数据
						//uniapp预览轮播图
						uni.previewImage({
							current: 0, //预览图片的下标
							urls: i //预览图片的地址，必须要数组形式，如果不是数组形式就转换成数组形式就可以
						})
					}
				});
			},
			async getcaigouma(){
				let res = await httpRequest.request('/api/user/getCzCardCode', 'GET', {})
				if(res.code==1){
					this.qrcodeurl = res.data.code
				}
			},
		}
	}
</script>

<style lang="scss" scoped>
	.xihbtn {
		width: 273rpx;
		height: 78rpx;
		border-radius: 39rpx 39rpx 39rpx 39rpx;
		font-size: 32rpx;
		display: flex;
		align-items: center;
		justify-content: center;
		font-weight: 500;
		color: #EE6D2D;
		border: 1rpx solid #EE6D2D;
	}
.erwem {
		margin: 20rpx auto 0;
		width: 320rpx;
		height: 320rpx;

		image {
			width: 100%;
			height: 100%;
		}
	}

</style>
